﻿using System;
using Pap.Core.Utilities;
using Pap.Web.Modules.Shared.ViewModel;
using Pap.Web.Utils;

namespace Pap.Web.Modules.Shared.Views
{
    /// <summary>
    /// 
    /// </summary>
    public partial class UserNotifications : BaseUserControl<UserNotificationsViewModel>
    {
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int loansExccededLimitWithoutStudy = this.ViewModel.GetLoansWithoutResearchExceededDelayLimitForUser(RegistryInfo.UserID);
                int loansExccededLimitWithStudy = this.ViewModel.GetLoansWithResearchExceededDelayLimitForUser(RegistryInfo.UserID);
                int loansExccededReminderWithoutStudy = this.ViewModel.GetLoansWithoutResearchExceededReminderDateForUser(RegistryInfo.UserID);
                int loansExccededReminderWithStudy = this.ViewModel.GetLoansWithResearchExceededReminderDateForUser(RegistryInfo.UserID);

                if (loansExccededLimitWithoutStudy == 0)
                    hlLoansExccededLimitWithoutStudy.Visible = false;
                else
                    hlLoansExccededLimitWithoutStudy.Text += loansExccededLimitWithoutStudy.ToString();

                if (loansExccededLimitWithStudy == 0)
                    hlLoansExccededLimitWithStudy.Visible = false;
                else
                    hlLoansExccededLimitWithStudy.Text += loansExccededLimitWithStudy.ToString();

                if (loansExccededReminderWithoutStudy == 0)
                    hlLoansExccededReminderWithoutStudy.Visible = false;
                else
                    hlLoansExccededReminderWithoutStudy.Text += loansExccededReminderWithoutStudy.ToString();

                if (loansExccededReminderWithStudy == 0)
                    hlLoansExccededReminderWithStudy.Visible = false;
                else
                    hlLoansExccededReminderWithStudy.Text += loansExccededReminderWithStudy.ToString();
            }
        }
    }
}